package com.superbytecode.cloud.web.transform.former;

import com.superbytecode.cloud.common.model.IDict;
import com.superbytecode.cloud.web.transform.annotation.TransformEnum;

import javax.annotation.Nonnull;
/**
 * All rights Reserved, Designed By www.super-master.com
 *
 * @ProjectName: beacon-cloud
 * @Package: com.superbytecode.cloud.web.transform.former
 * @ClassName: EnumTransformer
 * @Description: [枚举转换器]
 * <p> </p>
 * @Author: [Lance Ting]
 * @Date: 2024/10/22 12:18
 * @Version: V1.0
 * @Copyright: 2024 www.super-master.com Inc. All rights reserved.
 * TODO: 注意,本文件Lance Ting所作,如果转载或使用请标明具体出处!
 **/
public class EnumTransformer<T> implements Transformer<T, TransformEnum> {

    @SuppressWarnings("unchecked")
    @Override
    public String transform(@Nonnull T enumCode, @Nonnull TransformEnum annotation) {
        return IDict.obtainValueByCode((Class<? extends IDict<T>>) annotation.value(), enumCode);
    }
}